package com.umiwe.permission.service.impl;

import com.umiwe.entity.*;
import com.umiwe.permission.mapper.RolePermissionMapper;
import com.umiwe.permission.mapper.UserMapper;
import com.umiwe.permission.service.RolePermissionService;
import com.umiwe.utils.JsonUtils;
import com.umiwe.utils.RedisUtil;
import com.umiwe.utils.Result;
import com.umiwe.utils.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class RolePermissionServiceImpl implements RolePermissionService {

    @Autowired
    private RolePermissionMapper rolePermissionMapper;


    @Override
    public Result getRolePermissionById(Integer roleId) {
        List<UmiweRolePermissionVO> rolePermissionByRoleId = rolePermissionMapper.getRolePermissionByRoleId(roleId);
        if(rolePermissionByRoleId.size() > 0){
            return Result.success(JsonUtils.objectToJson(rolePermissionByRoleId));
        }else{
            return Result.error(ResultCode.ROLE_PERMISSION_NULL);
        }
    }
}
